package com.dyypdadmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dyypdadmin.pojo.Pets;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PetsDao extends BaseMapper<Pets> {

    @Insert("INSERT INTO pets (user_id, pet_name, breed, description) VALUES (#{user_id}, #{pet_name}, #{breed}, #{description})")
    int insertPet(@Param("user_id") Integer pet_id,
                  @Param("pet_name") String pet_name,
                  @Param("breed") String breed,
                  @Param("description") String description);

    @Update("UPDATE pets SET is_del=1 WHERE pet_id = #{pet_id}")
    int deletePetById(@Param("pet_id") Integer pet_id);

    @Update("UPDATE pets SET pet_name = #{pet_name}, breed = #{breed}, description = #{description} WHERE pet_id = #{pet_id}")
    int updatePet(@Param("pet_id") Integer pet_id,
                  @Param("pet_name") String pet_name,
                  @Param("breed") String breed,
                  @Param("description") String description);

    @Select("SELECT * FROM pets WHERE pet_id = #{pet_id}")
    Pets getPetById(@Param("pet_id") Integer pet_id);

    @Select("SELECT * FROM pets WHERE user_id = #{user_id}")
    List<Pets> getPetsByUserId(@Param("user_id") Integer user_id);

    @Select("select count(*) from pets")
    int getPetCounts();
}
